package com.example.fund.fundtrade;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.TextPaint;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.SimpleAdapter;
import android.widget.TextView;

import com.example.fund.BaseActivity;
import com.example.fund.Constant;
import com.example.fund.MainActivity;
import com.example.fund.R;
import com.example.fund.fundstocks.FundStageRise;
import com.example.fund.fundstocks.FundStocksUtil;
import com.example.fund.fundstocks.MyHScrollView;
import com.example.fund.info.FundInfo;
import com.example.fund.util.FundTradeUtil;
import com.example.fund.util.FundUtil;
import com.example.fund.util.FundUtil1;
import com.example.fund.util.FundUtil2;
import com.example.fund.util.StringUtil;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public class FundTradeList extends BaseActivity {

	private LinearLayout root;
	private TextView txtFundAccountNumber;
	private TextView txtFundAccountName;
	private TextView txtFundNumber;
	private TextView txtFundName;
	private TextView txtFundTradeTypeNumber;
	private TextView txtFundTradeTypeName;
	private TextView txtQuery;
	private TextView txtAddFundTrade;
	private TextView txtFundBatchTrade;
	private List<String> fundAccountList;
	private List<String> fundList;
	private List<String> fundTradeTypeList;
	private LinearLayout layoutSummary;
	//header
	private TextView txtAccount;
	private TextView txtFund;
	private TextView txtTradeType;
	private TextView txtTradeDate;
	private TextView txtTradePrice;
	private TextView txtTradeAmount;
	private TextView txtTradeRate;
	private TextView txtTradeQty;

	//自定义弹出选择框
	private PopupWindow popupWindow;
	private ListView popupList;

	//当前点击的TextView
	private TextView tv;
	private TextView numberTv;

	//表格数据
	private List<FundTradeInfo> dataList;

	private MyHScrollView headSrcrollView;
	private ListView mListView1;
	private MyAdapter myAdapter;
	private RelativeLayout mHead;

	private Map<String,Double> currPriceMap = new HashMap<String, Double>();//基金交易的当前价格
	private int bg1 = Color.rgb(5, 167, 247);
	private int bg2 = Color.rgb(233,244,251);

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
//		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//设置全屏
		setContentView(R.layout.fundtradelist_dialog);

		root = (LinearLayout)findViewById(R.id.root);
    	root.setBackgroundColor(bg1);
    	LinearLayout layoutTop = (LinearLayout)findViewById(R.id.layoutTop);
    	layoutTop.setBackgroundColor(bg1);

		txtFundAccountNumber = (TextView) findViewById(R.id.txtFundAccountNumber);
		txtFundAccountName = (TextView) findViewById(R.id.txtFundAccountName);
		txtFundNumber = (TextView) findViewById(R.id.txtFundNumber);
		txtFundName = (TextView) findViewById(R.id.txtFundName);
		txtFundTradeTypeNumber = (TextView) findViewById(R.id.txtFundTradeTypeNumber);
		txtFundTradeTypeName = (TextView) findViewById(R.id.txtFundTradeTypeName);
    	txtQuery = (TextView) findViewById(R.id.txtQuery);
		txtAddFundTrade = (TextView) findViewById(R.id.txtAddFundTrade);
		txtFundBatchTrade = (TextView) findViewById(R.id.txtFundBatchTrade);
		layoutSummary = (LinearLayout) findViewById(R.id.layoutSummary);//汇总信息

		txtAccount = (TextView) findViewById(R.id.txtAccount);
		txtFund = (TextView) findViewById(R.id.txtFund);
		txtTradeType = (TextView) findViewById(R.id.txtTradeType);
		txtTradeDate = (TextView) findViewById(R.id.txtTradeDate);
		txtTradePrice = (TextView) findViewById(R.id.txtTradePrice);
		txtTradeAmount = (TextView) findViewById(R.id.txtTradeAmount);
		txtTradeRate = (TextView) findViewById(R.id.txtTradeRate);
		txtTradeQty = (TextView) findViewById(R.id.txtTradeQty);
        //数据
		fundAccountList = FundTradeUtil.getFundAccountList();
		if (fundAccountList!=null && fundAccountList.size()>0)
		{
			txtFundAccountName.setText(fundAccountList.get(0));
		}
		fundList = new LinkedList<String>();
		fundTradeTypeList = new LinkedList<String>();
		fundTradeTypeList.add("0-交易类型");
		fundTradeTypeList.add("1-申购");
		fundTradeTypeList.add("2-赎回");

    	//初始化自定义下拉框
        View contentView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.popupwindow, null);
        contentView.setBackgroundColor(bg2);
        popupWindow = new PopupWindow(root, 500, 900);
        popupWindow.setContentView(contentView);
        popupList = (ListView) contentView.findViewById(R.id.popupList);
        popupList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        popupWindow.setFocusable(true);
        popupWindow.setOutsideTouchable(true);
        popupWindow.setBackgroundDrawable(new ColorDrawable(0));

		mHead = (RelativeLayout) findViewById(R.id.head);
		mHead.setFocusable(true);
		mHead.setClickable(true);
		mHead.setBackgroundColor(Color.parseColor("#b2d235"));
		mHead.setOnTouchListener(new ListViewAndHeadViewTouchLinstener());

		mListView1 = (ListView) findViewById(R.id.listView1);
		mListView1.setOnTouchListener(new ListViewAndHeadViewTouchLinstener());

		headSrcrollView = (MyHScrollView) mHead.findViewById(R.id.horizontalScrollView1);

		initData();
		initListener();
		txtQuery_OnClickListener();
//		mListView1.setSelection(selection);
	}


	/**
	 * 初始化数据
	 */
	private void initData() {
    	Bundle dataContext = this.getIntent().getExtras();
    	if(dataContext!=null)
    	{
    	}
	}

	/**
	 * 注册事件
	 */
	private void initListener() {
		//账户点击弹出下拉框
		txtFundAccountName.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View arg0)
			{
				fundAccountList = FundTradeUtil.getFundAccountList();
				initPopWindow(txtFundAccountNumber,(TextView)arg0,fundAccountList.toArray());
			}
		});

		//基金点击弹出下拉框
		txtFundName.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View arg0)
			{
				fundList = FundTradeUtil.getTradeFundNameList();
				fundList.add(0,"基金");
				initPopWindow(txtFundNumber,(TextView)arg0,fundList.toArray());
			}
		});

		//基金点击弹出下拉框
		txtFundTradeTypeName.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View arg0)
			{
				initPopWindow(txtFundTradeTypeNumber,(TextView)arg0,fundTradeTypeList.toArray());
			}
		});

    	//下拉框选中事件
    	popupList.setOnItemClickListener(new OnItemClickListener()
    	{
    		@Override
    		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3)
    		{
    			String text = ((TextView)arg1).getText().toString();
    			if(text.indexOf("-")>0)
    			{
    				String[] textArr = text.split("-");
    				if(textArr.length>=2)
    				{
    					numberTv.setText(textArr[0]);
    					tv.setText(textArr[1]);
    				}else{
    					numberTv.setText("");
    					tv.setText(text);
    				}
    			}else
    			{
    				numberTv.setText("");
    				tv.setText(text);
    			}
    			popupWindow.dismiss();
    		}
    	});

    	//查询按钮点击事件
    	txtQuery.setOnClickListener(new OnClickListener()
    	{
    		@Override
    		public void onClick(View arg0)
    		{
    			txtQuery_OnClickListener();
    		}
    	});

    	//点击新增交易记录
		txtAddFundTrade.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				txtAddFundTrade_onClick(v);
			}
		});
		//点击量化交易
		txtFundBatchTrade.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				txtFundBatchTrade_onClick(v);
			}
		});
	}

	/**
	 * 查询事件
	 * @param
	 */
	public void txtQuery_OnClickListener() {
		String fundAccountName = txtFundAccountName.getText().toString();
		String fundName = txtFundName.getText().toString();
		String fundNumber = FundUtil.getFundNumber(fundName);
		String fundTypeNumber = txtFundTradeTypeNumber.getText().toString();
		if ("0".equals(fundTypeNumber))
        {
            fundTypeNumber = "";
        }
		dataList = FundTradeUtil.getFundTradeList(fundAccountName, fundNumber,fundTypeNumber);

		myAdapter = new MyAdapter(this, R.layout.fundtradelist_header,dataList,headSrcrollView);
		mListView1.setAdapter(myAdapter);
	}


	/**
	 * 点击新增交易记录
	 * @param v
	 */
	protected void txtAddFundTrade_onClick(View v)
	{
		String fundAccountName = txtFundAccountName.getText().toString();
		if ("账户".equals(fundAccountName))
		{
			fundAccountName = "";
		}
		String fundName = txtFundName.getText().toString();
		if("基金".equals(fundName))
		{
			fundName = "";
		}
		String fundNumber = FundUtil.getFundNumber(fundName);

		FundTradeDialog dialog = new FundTradeDialog();
		dialog.setParentActivity(this);
		Bundle bundle = new Bundle();
		bundle.putString("account", fundAccountName);
		bundle.putString("fundName", fundName);
		bundle.putString("fundNumber", fundNumber);

		dialog.setArguments(bundle);
		dialog.show(getFragmentManager(), "dialog_fragment");
	}

	/**
	 * 点击新增交易记录
	 * @param v
	 */
	protected void txtFundBatchTrade_onClick(View v)
	{
		FundBatchTradeDialog dialog = new FundBatchTradeDialog();
		dialog.setParentActivity(this);
		Bundle bundle = new Bundle();

		dialog.setArguments(bundle);
		dialog.show(getFragmentManager(), "dialog_fragment");
	}

    /**
     * 设置返回值
     */
    private void setResult()
    {
    	Intent dataContext = this.getIntent();
    	setResult(20, dataContext);
    }

    /**
     * 初始化弹出下拉框，
     * 适用范围：时间区间、涨幅、跌幅
     * @param view
     * @param objects
     */
	@SuppressWarnings("unchecked")
	private void initPopWindow(TextView numberView,TextView view,final Object[] objects){
        ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, objects)
        {
        	@Override
        	public View getView(int position, View convertView, ViewGroup parent) {
        		TextView mTextView = new TextView(getApplicationContext());
                mTextView.setText(objects[position].toString());
                mTextView.setTextSize(15);
                mTextView.setTextColor(bg1);
                mTextView.setPadding(30, 10, 0, 10);
        		return mTextView;
        	}
        };
        popupList.setAdapter(adapter);
        String text = view.getText().toString();
        for(int i=0;i<objects.length;i++)
        {
        	if(objects[i]!=null && objects[i].toString().contains(text))
        	{
        		popupList.setSelection(i);
        		break;
        	}
        }
        popupWindow.showAsDropDown(view);
        tv = view;
        numberTv = numberView;
    }

    @Override
    protected void onResume()
    {
    	if(getRequestedOrientation()!=ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)//横屏
    	{
   // 		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    	}
    	super.onResume();
    }

	/**
	 * 基金交易列表 基金字段点击打开编辑交易记录界面
	 * @param
	 * @return
	 */
	protected void txtFund_OnClick(View view, FundTradeInfo info)
	{
		if (info==null)
		{
			return;
		}

		FundTradeDialog dialog = new FundTradeDialog();
		dialog.setParentActivity(this);
		Bundle bundle = new Bundle();
		bundle.putInt("id", info.getId());
		bundle.putString("account", info.getAccount());
		bundle.putString("fundName", info.getFundName());
		bundle.putString("fundNumber", info.getFundNumber());
		bundle.putString("tradeDate", info.getDate());
		bundle.putInt("tradeType",info.getType());
		bundle.putDouble("tradePrice",info.getTradePrice());
		bundle.putDouble("tradeAmount",info.getTradeAmount());
		bundle.putDouble("tradeRate",info.getTradeRate());
		bundle.putDouble("tradeQty",info.getTradeQty());

		dialog.setArguments(bundle);
		dialog.show(getFragmentManager(), "dialog_fragment");
	}


	class ListViewAndHeadViewTouchLinstener implements View.OnTouchListener {

		@Override
		public boolean onTouch(View arg0, MotionEvent arg1) {
			//当在列头 和 listView控件上touch时，将这个touch的事件分发给 ScrollView
			headSrcrollView.onTouchEvent(arg1);
			return false;
		}
	}

	public class MyAdapter extends BaseAdapter {
		private List<HorizontalScrollView> mList = new ArrayList<HorizontalScrollView>();
        private List<FundTradeInfo> list;
		private int id_row_layout;
		private LayoutInflater mInflater;
		private ViewHolder holder = null;

		public MyAdapter(Context context, int id_row_layout,List<FundTradeInfo> list,MyHScrollView headSrcrollView) {
			super();
            this.list = list;
			this.id_row_layout = id_row_layout;
			mInflater = LayoutInflater.from(context);
			mList.add(headSrcrollView);
			headSrcrollView.setOnScrollChangedListener(mList);
		}

		@Override
		public int getCount() {
            int ret = 0;
            if(list!=null){
                ret = Math.min(200,list.size());
            }
            return ret;
		}

		@Override
		public Object getItem(int position) {
            return list.get(position);
		}

		@Override
		public long getItemId(int position) {
            return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parentView) {
        	final FundTradeInfo info = (FundTradeInfo) this.getItem(position);
            final int position1 = position;
			if (convertView == null) {
				synchronized (FundTradeList.this) {
					convertView = mInflater.inflate(id_row_layout, null);
					holder = new ViewHolder();

					MyHScrollView scrollView1 = (MyHScrollView) convertView.findViewById(R.id.horizontalScrollView1);

					holder.scrollView = scrollView1;
					holder.txtAccount = (TextView) convertView.findViewById(R.id.txtAccount);
					holder.txtFund = (TextView) convertView.findViewById(R.id.txtFund);
					holder.txtTradeType = (TextView) convertView.findViewById(R.id.txtTradeType);
					holder.txtTradeDate = (TextView) convertView.findViewById(R.id.txtTradeDate);
					holder.txtTradePrice = (TextView) convertView.findViewById(R.id.txtTradePrice);
					holder.txtTradeAmount = (TextView) convertView.findViewById(R.id.txtTradeAmount);
					holder.txtTradeRate = (TextView) convertView.findViewById(R.id.txtTradeRate);
					holder.txtTradeQty = (TextView) convertView.findViewById(R.id.txtTradeQty);
		//			holder.txtValue = (TextView) convertView.findViewById(R.id.txtValue);
		//			holder.txtChg = (TextView) convertView.findViewById(R.id.txtChg);
		//			holder.txtTradeAmountTotal = (TextView) convertView.findViewById(R.id.txtTradeAmountTotal);
		//			holder.txtTradeQtyTotal = (TextView) convertView.findViewById(R.id.txtTradeQtyTotal);
					holder.txtValueTotal = (TextView) convertView.findViewById(R.id.txtValueTotal);
		//			holder.txtChgTotal = (TextView) convertView.findViewById(R.id.txtChgTotal);
					mList.add(scrollView1);
					scrollView1.setOnScrollChangedListener(mList);
					convertView.setTag(holder);
				}
			} else {
				holder = (ViewHolder) convertView.getTag();
			}
			if (info.getTotalType()==1)//总计
			{
				holder.txtAccount.setText(StringUtil.dealNull(info.getAccount()));
				holder.txtAccount.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
				holder.txtFund.setText("合计(万元)");
				holder.txtFund.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
				holder.txtTradeType.setText("汇总");

				holder.txtTradePrice.setText("");
				String costAmountTotal = StringUtil.dealBigDecimal(info.getCostAmountTotal()/10000.00d,4);
				String redeemAmountTotal = StringUtil.dealBigDecimal(info.getRedeemAmountTotal()/10000.00d,4);
				String investAmountStr = StringUtil.dealBigDecimal(info.getInvestAmountTotal()/10000.00d,4);
				holder.txtTradeAmount.setText("申购:"+costAmountTotal+"\n"+"赎回:"+redeemAmountTotal);
				holder.txtTradeAmount.setGravity(Gravity.LEFT);
				holder.txtTradeRate.setText("");
				String valueTotal = StringUtil.dealBigDecimal(info.getValueTotal()/10000.00d,4);
				double chg = info.getValueTotal()+info.getRedeemAmountTotal()-info.getCostAmountTotal();
				String chgStr = StringUtil.dealBigDecimal(chg/10000.00d,4);
				String chgTotal = "";
				if (info.getInvestAmountTotal()>0)
				{
					chgTotal = StringUtil.dealBigDecimal(chg*100.00d/info.getInvestAmountTotal(),2);
				}
				holder.txtValueTotal.setText("成本:"+investAmountStr+"\n"+"市值:"+valueTotal+"\n"+"盈亏:"+chgStr+"("+chgTotal+"%)");
				if (chg<0)
				{
					holder.txtValueTotal.setTextColor(Constant.colorSet[3]);
				}else
				{
					holder.txtValueTotal.setTextColor(Constant.colorSet[6]);
				}
				holder.txtTradeQty.setText("");
				if (info.getValueTotal()<=1)
				{
					holder.txtTradeDate.setText("");
					convertView.setBackgroundColor(Color.rgb(222,222,222));
				}else {
					holder.txtTradeDate.setText(StringUtil.dealNull(info.getDate()));
					convertView.setBackgroundColor(Color.rgb(251,236,136));
				}
			}
			else if (info.getTotalType()==2)//小计
			{
				holder.txtAccount.setText(StringUtil.dealNull(info.getAccount()));
				holder.txtAccount.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
				holder.txtFund.setText(StringUtil.dealNull(info.getFundName()));
				holder.txtFund.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
				holder.txtTradeType.setText("汇总");

				String costAmountTotal = StringUtil.dealBigDecimal(info.getCostAmountTotal(),0);
				String redeemAmountTotal = StringUtil.dealBigDecimal(info.getRedeemAmountTotal(),0);
				holder.txtTradeAmount.setText("申购:"+costAmountTotal+"\n"+"赎回:"+redeemAmountTotal);
				holder.txtTradeAmount.setGravity(Gravity.LEFT);
				holder.txtTradeRate.setText("");
				String valueTotal = StringUtil.dealBigDecimal(info.getValueTotal(),0);
				double chg = info.getValueTotal()+info.getRedeemAmountTotal()-info.getCostAmountTotal();
				String chgStr = StringUtil.dealBigDecimal(chg,0);
				String chgTotal = "";
				if (info.getCostAmountTotal()>0)
				{
					chgTotal = StringUtil.dealBigDecimal(chg*100.00d/info.getCostAmountTotal(),2);
				}
				holder.txtValueTotal.setText("市值:"+valueTotal+"\n"+"盈亏:"+chgStr+"("+chgTotal+"%)");
				if (chg<0)
				{
					holder.txtValueTotal.setTextColor(Constant.colorSet[3]);
				}else
				{
					holder.txtValueTotal.setTextColor(Constant.colorSet[6]);
				}
				holder.txtTradeQty.setText("");
				if (info.getValueTotal()<=1)
				{
					holder.txtTradeDate.setText("");
                    holder.txtTradePrice.setText("");
					convertView.setBackgroundColor(Color.rgb(222,222,222));
				}else {
					holder.txtTradeDate.setText(StringUtil.dealNull(info.getDate()));
                    holder.txtTradePrice.setText(StringUtil.dealBigDecimal(info.getTradePrice(),4));
					convertView.setBackgroundColor(Color.rgb(255,250,205));
				}
                holder.txtTradePrice.setTextColor(Constant.colorSet[0]);
				currPriceMap.put(info.getFundNumber(),info.getTradePrice());
			}else
			{
				holder.txtAccount.setText(StringUtil.dealNull(info.getAccount()));
				holder.txtAccount.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
				holder.txtFund.setText(StringUtil.dealNull(info.getFundName()));
				holder.txtFund.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
				holder.txtTradeType.setText(String.valueOf(info.getType()==1?"申购":"赎回"));
				holder.txtTradeDate.setText(StringUtil.dealNull(info.getDate()));
				double tradePrice = info.getTradePrice();
				Double currPrice = currPriceMap.get(info.getFundNumber());
				String priceStr = StringUtil.dealBigDecimal(tradePrice,4);
				if(tradePrice>0 && currPrice!=null && currPrice>0)
				{
					priceStr += "\n比当前:"+StringUtil.dealBigDecimal((currPrice-tradePrice)*100.00d/tradePrice,2)+"%";
					if (currPrice<tradePrice)
					{
						holder.txtTradePrice.setTextColor(Constant.colorSet[3]);
					}else if(currPrice>tradePrice)
					{
						holder.txtTradePrice.setTextColor(Constant.colorSet[6]);
					}else
                    {
                        holder.txtTradePrice.setTextColor(Constant.colorSet[0]);
                    }
				}
				holder.txtTradePrice.setText(priceStr);
				holder.txtTradeAmount.setText(StringUtil.dealBigDecimal(info.getTradeAmount(),2));
				holder.txtTradeAmount.setGravity(Gravity.RIGHT);
				holder.txtTradeRate.setText(StringUtil.dealBigDecimal(info.getTradeRate(),2));
				holder.txtTradeQty.setText("成交:"+StringUtil.dealBigDecimal(info.getTradeQty(),4)+"\n"+"累积:"+StringUtil.dealBigDecimal(info.getTradeQtyTotal(),4));
				holder.txtTradeQty.setGravity(Gravity.LEFT);

				String valueTotal = StringUtil.dealBigDecimal(info.getValueTotal(),2);
				double chg = info.getValueTotal()+info.getRedeemAmountTotal()-info.getCostAmountTotal();
				String chgStr = StringUtil.dealBigDecimal(chg,2);
				String chgTotal = "";
				if (info.getCostAmountTotal()>0)
				{
					chgTotal = StringUtil.dealBigDecimal(chg*100.00d/info.getCostAmountTotal(),2);
				}
				holder.txtValueTotal.setText("市值:"+valueTotal+"\n"+"盈亏:"+chgStr+"("+chgTotal+"%)");
				holder.txtValueTotal.setTextColor(Color.BLACK);
				if (info.getType()==1)
				{
					convertView.setBackgroundColor(Color.WHITE);
				}else
				{
					convertView.setBackgroundColor(Color.rgb(224,234,247));
				}

			}
			holder.txtFund.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					if (info.getTotalType()>0)
					{
						return;
					}
					txtFund_OnClick(v,info);
				}
			});

			return convertView;
		}

		class ViewHolder {
			TextView txtAccount;
			TextView txtFund;
			TextView txtTradeType;
			TextView txtTradeDate;
			TextView txtTradePrice;
			TextView txtTradeAmount;
			TextView txtTradeRate;
			TextView txtTradeQty;
			TextView txtValue;
			TextView txtChg;
			TextView txtTradeAmountTotal;
			TextView txtTradeQtyTotal;
			TextView txtValueTotal;
			TextView txtChgTotal;
			
			HorizontalScrollView scrollView;
		}
	}// end class my

	

}